import 'package:cassie_desktop/router/routers.dart';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/foundation.dart';

import 'package:flutter_acrylic/flutter_acrylic.dart' as flutter_acrylic;
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:get/get_state_manager/src/simple/get_state.dart';
import 'init_context.dart';
import 'theme.dart';
import 'package:bitsdojo_window/bitsdojo_window.dart';

void main() async {
  await initContext();
  runApp(const Main());
  doWhenWindowReady(() {
    final win = appWindow;
    const initialSize = Size(1000, 800);
    win.minSize = initialSize;
    win.size = initialSize;
    win.alignment = Alignment.center;
    win.title = "Custom window with Flutter";
    win.show();
  });


}
class Main extends StatelessWidget {
  const Main({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final appTheme = Get.find<AppTheme>();

    return GetBuilder<AppTheme>(
        builder: (_) => FluentApp(
              navigatorKey: navigatorKey,
              themeMode: appTheme.mode,
              debugShowCheckedModeBanner: false,
              initialRoute: "/home",
              onGenerateRoute: routeGenerator,
              color: appTheme.color,
              darkTheme: ThemeData(
                brightness: Brightness.dark,
                accentColor: appTheme.color,
                visualDensity: VisualDensity.standard,
                focusTheme: FocusThemeData(
                  glowFactor: is10footScreen() ? 2.0 : 0.0,
                ),
              ),
              theme: ThemeData(
                accentColor: appTheme.color,
                visualDensity: VisualDensity.standard,
                focusTheme: FocusThemeData(
                  glowFactor: is10footScreen() ? 2.0 : 0.0,
                ),
              ),
              locale: appTheme.locale,
              builder: (context, child) {
                return Directionality(
                  textDirection: appTheme.textDirection,
                  child: NavigationPaneTheme(
                    data: NavigationPaneThemeData(
                      backgroundColor: appTheme.windowEffect !=
                              flutter_acrylic.WindowEffect.disabled
                          ? Colors.transparent
                          : null,
                    ),
                    child: child!,
                  ),
                );
              },
            ));
  }


}


